package com.fengye.algorithms.leecode;

/**
 * @Author fengye
 * @Date 2023/4/10 9:37
 **/
public class SubtractProductAndSum1281 {
    public int subtractProductAndSum(int n) {
        if(n<10) {
            return 0;
        }

        int j = 1;
        int a = 0;

        while (n > 0) {
            int t = n % 10;
            j *= t;
            a += t;
            n /= 10;
        }

        return j - a;
    }
}
